package com.b511.swpu.cementbackend.controller;
import com.b511.swpu.cementbackend.dto.input.BoreholeConditionInputDto;
import com.b511.swpu.cementbackend.dto.output.JsonDto;
import com.b511.swpu.cementbackend.service.DataBrowserService;
import com.b511.swpu.cementbackend.service.DataQueryService;
import com.b511.swpu.cementbackend.service.MetaDictService;
import com.b511.swpu.cementbackend.service.PorePressureService;
import com.b511.swpu.cementbackend.dto.input.MetaDictInputDto;
import com.b511.swpu.cementbackend.entity.PorePressure;
import com.b511.swpu.cementbackend.service.impl.DataBrowserServiceImpl;
import com.b511.swpu.cementbackend.util.R;
import io.swagger.annotations.Api;

import org.springframework.data.domain.PageRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(value = "数据浏览", tags = {"数据浏览"})
@RestController
@RequestMapping("/dataBrowser")
public class DataBrowserController {

   private final DataBrowserService dataBrowserService;

   private final DataQueryService dataQueryService;

   public DataBrowserController( DataBrowserService dataBrowserService, DataQueryService dataQueryService) {
        this.dataBrowserService = dataBrowserService;
        this.dataQueryService = dataQueryService;
    }

    @GetMapping("/{num}/{size}")
    public R getPorePressureByCondition(@PathVariable int num, @PathVariable int size, @ModelAttribute BoreholeConditionInputDto boreholeConditionInputDto) throws Exception {
        return dataBrowserService.getDataByCondition(boreholeConditionInputDto,"STRATUM" ,PageRequest.of(num, size));
    }

    @GetMapping("/tableHead")
    public R getTableHead(){
        // TODO: 动态表头实现：根据模块名，获取动态数据
        List<JsonDto> listDto = new ArrayList<>();

        JsonDto json1 = new JsonDto();
        json1.setProperty("FORMATION");
        json1.setLabel("地层标识");

        JsonDto json2 = new JsonDto();
        json2.setProperty("MEMBER");
        json2.setLabel("系");

        listDto.add(json1);
        listDto.add(json2);
        return R.ok().putData(listDto);
    }

    // 通过井名查询 CM_WorkBaseInfo
    @GetMapping("/base/{wellName}")
    public R getWorkBaseInfo(@PathVariable String wellName){
        return dataQueryService.getWorkBaseInfo(wellName);
    }


}
